<template>
	<!-- 为你省钱瀑布流 -->
	<view class="" style="height: 100%;">
		<view class="waterfall" style="background: #f5f5f5;">
			<uv-waterfall ref="waterfall" v-model="goodsList" :add-time="50" column-count="2" left-gap="10"
				right-gap="10" column-gap="8" column-width="40" @changeList="changeList" @clear="clear">
				<template v-slot:list1>
					<view>
						<view v-for="(item, index) in list1" :key="item.id" class="waterfall-item"
							@click="todetail(item.id)">
							<view class="waterfall-item__image">
								<!-- 									<uv-image :src="item.large" mode="widthFix" :width="item.width+'px'">
										<template v-slot:loading>
										</template>
									</uv-image> -->
								<image v-if="item.hasVideo" src="https://image.hzwltb69.com/app/imgs/chat/live.gif"
									class="lives" mode=""></image>
								<image :src="item.img" mode="widthFix">
								</image>
							</view>
							<view class="p-title">
								{{item.name}}
							</view>
							<!-- 								<view class="butie-box">
									<view class="butie">
										补贴:{{((item.price-item.cost)*rebate/100).toFixed(2)}}元
									</view>
								</view> -->
							<!-- <view class="p-pirce">
								<view class="">
									￥{{item.price}}
								</view>
								<view class="cat">
									<image src="https://image.hzwltb69.com/app/date/2023/cat.png" alt="">
								</view>
							</view> -->
							<view class="p-pirce">
								<view class="">
									<text style="font-size: 22rpx;margin-right: 2rpx;">￥</text>{{item.price}}
								</view>
								<view class="cat">抢购</view>
							</view>
							<!-- <view class="line" v-if="item.paySales != 0"></view>
							<view class="flagWord" v-if="item.paySales != 0">回头客{{item.paySales}}</view> -->
						</view>
					</view>
				</template>
				<template v-slot:list2>
					<view>
						<view v-for="(item, index) in list2" :key="item.id" class="waterfall-item"
							@click="todetail(item.id)">
							<view class="waterfall-item__image">
								<!-- 									<uv-image :src="item.large" mode="widthFix" :width="item.width+'px'">
										<template v-slot:loading>
										</template>
									</uv-image> -->
								<image v-if="item.hasVideo" src="https://image.hzwltb69.com/app/imgs/chat/live.gif"
									class="lives" mode=""></image>
								<image :src="item.img" mode="widthFix">
								</image>
							</view>
							<view class="p-title">
								{{item.name}}
							</view>
							<!-- 									<view class="butie-box">
										<view class="butie">
											补贴:{{((item.price-item.cost)*rebate/100).toFixed(2)}}元
										</view>
									</view> -->
							<!-- <view class="p-pirce">
								<view class="">
									￥{{item.price}}
								</view>
								<view class="cat">
									<image src="https://image.hzwltb69.com/app/date/2023/cat.png" alt="">
								</view>
							</view> -->
							<view class="p-pirce">
								<view class="">
									<text style="font-size: 22rpx;margin-right: 2rpx;">￥</text>{{item.price}}
								</view>
								<view class="cat">抢购</view>
							</view>
							<!-- <view class="line" v-if="item.paySales != 0"></view>
							<view class="flagWord" v-if="item.paySales != 0">回头客{{item.paySales}}</view> -->
						</view>
					</view>
				</template>
			</uv-waterfall>
		</view>
		<u-loadmore height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
	</view>
</template>

<script>
	export default {
		props: {
			rebate: {
				type: Number || String,
				default () {
					return 20
				}
			}
		},
		methods: {
			changeList(e) {
				this[e.name].push(e.value);
			},
			todetail(e) {
				this.$Router.push({
					path: '/pages/goods/detail',
					query: {
						id: e,
					}
				})
			},
			clear() {
				this.page = 0
				this.goodsList = []
				this.list1 = []
				this.list2 = []
				this.getGoodsList()
			},
			// 商品列表
			getGoodsList() {
				let that = this;
				that.loadStatus = 'loading';
				that.$http('common.youxuandetailnew', {
					cateId: that.cateId,
					page: that.page,
					size: 10,
				}).then(res => {
					uni.setNavigationBarTitle({
						title: res.theme
					})
					if (res.productList.length > 0) {
						let list = res.productList
						that.goodsList.length == 0 ? that.goodsList = list : that.goodsList = that.goodsList
							.concat(list)
						list.length == 10 ? that.loadStatus = 'loadmore' : that.loadStatus = 'nomore'
					} else {
						// 没有更多
						that.loadStatus = "nomore"
						that.onEnd = true
					}
				});
			},
		},
		data() {
			return {
				onEnd: false,
				goodsList: [],
				cateId: '',
				page: 0,
				idData: '',
				list1: [], // 瀑布流第一列数据
				list2: [], // 瀑布流第二列数据
				loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
			}
		},
	}
</script>

<style lang="scss" scoped>
	image {
		width: 350rpx !important;
	}

	.waterfall {
		background: #f1f1f1;
	}

	.waterfall-item {
		overflow: hidden;
		margin-top: 10px;
		border-radius: 6px;
	}

	.waterfall-item {
		background: #fff;

		.p-title {
			width: 350rpx;
			margin-top: 10rpx;
			padding: 0 10rpx;
			word-break: break-all;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
			
			font-size: 28rpx;
			font-weight: 600;
			color: #030303;
		}

		.p-pirce {
			padding: 16rpx 10rpx 10rpx;
			display: flex;
			justify-content: space-between;
			color: #000;
			font-weight: 600;
			font-size: 32rpx;
			align-items: center;
		
			.cat {
				width: 86rpx;
				height: 46rpx;
				color: rgba(255, 255, 255, 1);
				background-color: rgba(238, 38, 50, 1);
				border-radius: 32rpx;
				font-size: 22rpx;
				line-height: 46rpx;
				text-align: center;
			}
		}

		.butie-box {
			padding: 10rpx;

			.butie {
				// width: 100rpx;
				color: #db5235;
				height: 50rpx;
				line-height: 50rpx;
				font-size: 25rpx;
				display: inline-block;
				border: 1px solid #db5235;
				padding: 0 20rpx 0 20rpx;
				border-radius: 20rpx;
			}
		}
	}

	.waterfall-item__ft {
		padding: 20rpx;
		background: #fff;

		&__title {
			margin-bottom: 10rpx;
			line-height: 48rpx;
			font-weight: 700;

			.value {
				font-size: 32rpx;
				color: #303133;
			}
		}

		&__desc .value {
			font-size: 28rpx;
			color: #606266;
		}

		&__btn {
			padding: 10px 0;
		}
	}

	.lives {
		width: 40rpx !important;
		height: 40rpx !important;
		position: absolute;
		bottom: 20rpx;
		right: 20rpx;
		z-index: 10;
	}

	.waterfall-item__image {
		position: relative;
	}
	
	.line {
		width: 320rpx;
		height: 2rpx;
		color: rgba(80, 80, 80, 1);
		background-color: rgba(238, 237, 237, 1);
		margin: 10rpx auto;
	}
	
	.flagWord {
		color: rgba(188, 142, 93, 1);
		font-size: 24rpx;
		margin: 0 0 20rpx 16rpx;
	}
</style>